import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const routers = new Router({
  routes: [
    {
      path: '/',
      name: 'index',
      redirect: 'logistics'
    },
    {
      path: '/logistics',
      name: 'Logistics',
      component: resolve => require(['@/views/logistics-view/index'], resolve),
      meta: { title: '荣运达大数据监测平台' }
    },
    {
      path: '/purchase',
      name: 'Purchase',
      component: resolve => require(['@/views/purchase-view/index'], resolve),
      meta: { title: '荣运达大数据监测平台' }
    },
    {
      path: '/warehouse',
      name: 'Warehouse',
      component: resolve => require(['@/views/warehouse-view/index'], resolve),
      meta: { title: '荣运达大数据监测平台' }
    },
    {
      path: '/privacy',
      name: 'Privacy',
      component: resolve => require(['@/views/article-view/index'], resolve),
      meta: { title: '单页文章' }
    }
  ]
})

// 路由守卫
routers.beforeEach((to, from, next) => {
  document.title = to.meta.title
  // console.log(to)
  // console.log(from)
  next()
})

export default routers
